<?php
require_once("../../../config.inc.php");
$isReloadable = false;
require_once("../../../app/_inc/include.php");
require_once("./_inc/layoutFunction.php");

$layout_alias = sxREQ('layout_alias');
$layout = sxREQ('layout');
$variable = sxREQ('variable');
if(sxREQ("reqtype") == "delete"){
	$errMsg .= layoutVarDel();
}
$sSQL = "SELECT * FROM layout_variable "
	." WHERE layout = '".sxRAS('layout')."' "
	." AND  layout = '".sxRAS('layout')."'"
	." AND  variable = '".sxRAS('variable')."'";
$objSDAO->query($sSQL,"selLOV");
$row=$objSDAO->fetch('selLOV');

$sSQL = "SELECT * FROM domain WHERE frequent = 'Y' OR domain = '".$row['domain']."'";
$objSDAO->query($sSQL,"domain");
$rowDo=$objSDAO->fetch('domain');

$aOpz = array("kMenu"=>'pro.lay', "isReloadable"=>$isReloadable);
echo(headerHTML($aOpz));
$sLinkDel = "layoutVarView.php?layout=$layout&layout_alias=$layout_alias&variable=$variable"
	."&reqtype=delete&xsn=".XSN;
?>
<script language="JavaScript" type="text/javascript">
function confDel(){
	if (confirm("Confirm ?")) {
		document.location.href = "<?=$sLinkDel?>";
	}
}
</script>  
<?php
echo(bodyHTML($aOpz));


echo getLOHeader($layout);

$aCmd = array("del"=>array("pag"=>"javascript:confDel();",
										"title"=>_t("delete"),
										"text"=>_t("delete")
										),
					"mod"=>array("pag"=>"layoutVarMod.php?layout=$layout&layout_alias=$layout_alias&variable=$variable",
										"title"=>_t("change"),
										"text"=>_t("change")
										),
					"back"=>array()
					);
$sHtmlCmd = commandsHTML($aCmd);
echo $sHtmlCmd;	

if ($layout_alias=='W') {
	$loaDes = 'simple memory variable';
} elseif ($layout_alias=='X') {
	$loaDes = '1 dimension array memory variable';
} else {
	$loaDes = '???';
}
echo("<table class='tabl01' width=\"100%\" cellpadding=\"3\" cellspacing=\"2\">\n");
echo("<tr>" .
		"<td class=\"titl01\"colspan=\"2\">Layout variable $layout_alias - $loaDes</td>" .
	"</tr>\n");
echo("<tr>" .
			"<td class=\"labl01\">Name*</td>" .
			"<td class=\"text01\">".$layout_alias."_".$row['variable']."</td>" .
		"</tr>\n");
echo("<tr>" .
			"<td class=\"labl01\">Domain</td>" .
			"<td class=\"text01\">" .$row['domain']." - ".$rowDo['description'].
			"</td>\n</tr>\n");
echo("<tr>" .
			"<td class=\"labl01\">Length</td>" .
			"<td class=\"text01\">" .$row['length']."</td>" .
		"</tr>\n");
echo("<tr>" .
			"<td class=\"labl01\">Decimals</td>" .
			"<td class=\"text01\">" .$row['decimals']."</td>" .
		"</tr>\n");
echo("</table>");
echo $sHtmlCmd;	
echo("</form>");
echo("</td>\n</tr>\n</table>\n");
echo(footerHTML());
exit();

function layoutVarDel(){
 	global $objSDAO;
	$errMsg = "";
	$layout = sxRAS("layout");
	$layout_alias = sxRAS("layout_alias");
	$variable = sxRAS("variable");
	$sSQL = "DELETE FROM layout_variable " .
				" WHERE layout='$layout' " .
				" AND layout_alias='$layout_alias' " .
				" AND variable='$variable'";	
	$objSDAO->query($sSQL,"del");
	$url = $_SESSION[USEROBJ]->getHistory(-1, true);
	serverRedir($url);
	return 'abnormal end';
 } 
